package com.gientech.springexercise.controller.rocketMQ;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName Producer
 * @Description TODO
 * @Author zhangfantong
 * @Date 2023/2/24 22:48
 * @Version 1.0
 */
@RestController
public class Producer {
    @Resource
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("/push")
    public String get() {
        String s = rocketMQTemplate.getProducer().getNamesrvAddr();
        System.out.println(s);
        rocketMQTemplate.convertAndSend("mytopic","helloworld" );

        return "生产……";
    }

    @RequestMapping("/newUser")
    public String userReg() {
        String user01 = "name: jack, password: 111";
        rocketMQTemplate.convertAndSend("user1", user01 );

        return "用户注册";
    }
}
